<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查看推广数据-Manager</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/plupload/plupload.full.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-ui/jquery-ui.js"></script>

<script src="${pageContext.request.contextPath}/js/bootstrap/bootstrap.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/bootstrap-table.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/locale/bootstrap-table-zh-CN.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/plugins/tableExport.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/plugins/table-export.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/table/plugins/jquery.base64.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/layui/layui.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/layui/lay/modules/laydate.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/ui/layui/lay/modules/form.js" type="text/javascript"></script>
  <script src="${pageContext.request.contextPath}/ui/layui/lay/modules/element.js" type="text/javascript"></script>
  
 <link rel="stylesheet" href="${pageContext.request.contextPath}/ui/layui/css/modules/laydate/laydate.css" >
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/jquery-css/jquery-ui.css">
 <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap-css/bootstrap.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/ui/table/bootstrap-table.css">
 <link rel="stylesheet" href="${pageContext.request.contextPath}/ui/layui/css/layui.css" >
 <link rel="stylesheet" href="${pageContext.request.contextPath}/ui/layui/css/global.css" >
 <link rel="stylesheet" href="${pageContext.request.contextPath}/css/jquery-css/jquery-ui.css">

 <style>
  .container{
   width:95%;
  }
   .modal-industry{
  	width:900px;
  }
  .modal-body{
    max-height:750px
  }
   .modal-body-industry{
  	height:280px;
  } 
  
  .modal-backdrop{
   position:fixed;
   top:0;
   right:0;
   bottom:0;
   left:0;
   z-index:0;
   background-color:#FFFFFF;   
  }
  </style>

</head>
<body>
<%@include file="/webpage/frame/top.jsp" %>
<div class="container">
	<div id="topContent" class="layui-form-pane" style="margin-bottom:50px;">
		<div class="layui-form-item">
			<label class="layui-form-label">推广时段</label>
			<div class="layui-input-inline">
  				<input class="layui-input" name="beginTime" placeholder="开始日" id="LAY_demorange_s" style="margin-left:3px;">
			</div>			
			<div class="layui-input-inline">
  				<input class="layui-input" name="endTime" placeholder="结束日" id="LAY_demorange_e">
 			</div> 
			 			
			<div class="layui-inline">
		   		<label class="layui-form-label">推广计划</label>
		   		<div class="layui-input-inline">
		      	<select name="promotionPlan" id = "promotionPlan"  lay-verify="required" lay-search="required" style="margin-left:3px;">
		        		<option value="">选择全部</option>         	
		      	</select>
		   		</div>
			</div>
<!-- 			<div class="layui-inline">
		   		<label class="layui-form-label">推广单元</label>
		   		<div class="layui-input-inline">
		      	<select name="promotionUnit" id = "promotionUnit"  lay-verify="required" lay-search="">
		        		<option value="">直接选择或搜索选择</option>         	
		      	</select>
		   		</div>    		
			</div> -->			
		</div>
		
		  <div class="layui-form-item">
		    <div class="layui-inline">
		      <label class="layui-form-label">第一象限</label>
		      <input id="quadrant_1" type="hidden"/>
		      <input id="industry_1" type="hidden"/>
		      <div class="layui-input-inline" style="width: 100px;">
		        <input id="consumeRateMin_1" type="text" maxlength="20" placeholder="最小值" autocomplete="off" class="layui-input" style="height:35px;margin-left:3px;">
		      </div>
		      <div class="layui-form-mid">-</div>
		      <div class="layui-input-inline" style="width: 100px;">
		        <input id="consumeRateMax_1" type="text" maxlength="20" placeholder="最大值" autocomplete="off" class="layui-input" style="height:35px;margin-left:3px;">
		      </div>
		    </div>			    
		    <div class="layui-inline">
		      <label class="layui-form-label">第二象限</label>
		      <input id="quadrant_2" type="hidden"/>
		      <input id="industry_2" type="hidden"/>
		      <div class="layui-input-inline" style="width: 100px;">
		        <input id="consumeRateMin_2" type="text" maxlength="20" placeholder="最小值" autocomplete="off" class="layui-input" style="height:35px;margin-left:3px;">
		      </div>
		      <div class="layui-form-mid">-</div>
		      <div class="layui-input-inline" style="width: 100px;">
		        <input id="consumeRateMax_2" type="text" maxlength="20" placeholder="最大值" autocomplete="off" class="layui-input" style="height:35px;margin-left:3px;">
		      </div>
		    </div>			    
		  </div>	  
		  <div class="layui-form-item">
		    <div class="layui-inline">
		      <label class="layui-form-label">第三象限</label>
		      <input id="quadrant_3" type="hidden"/>
		      <input id="industry_3" type="hidden"/>
		      <div class="layui-input-inline" style="width: 100px;">
		        <input id="consumeRateMin_3" type="text" maxlength="20" placeholder="最小值" autocomplete="off" class="layui-input" style="height:35px;margin-left:3px;">
		      </div>
		      <div class="layui-form-mid">-</div>
		      <div class="layui-input-inline" style="width: 100px;">
		        <input id="consumeRateMax_3" type="text" maxlength="20" placeholder="最大值" autocomplete="off" class="layui-input" style="height:35px;margin-left:3px;">
		      </div>
		    </div>			    
		    <div class="layui-inline">
		      <label class="layui-form-label">第四象限</label>
		      <input id="quadrant_4" type="hidden"/>
		      <input id="industry_4" type="hidden"/>
		      <div class="layui-input-inline" style="width: 100px;">
		        <input id="consumeRateMin_4" type="text" maxlength="20" placeholder="最小值" autocomplete="off" class="layui-input" style="height:35px;margin-left:3px;">
		      </div>
		      <div class="layui-form-mid">-</div>
		      <div class="layui-input-inline" style="width: 100px;">
		        <input id="consumeRateMax_4" type="text" maxlength="20" placeholder="最大值" autocomplete="off" class="layui-input" style="height:35px;margin-left:3px;">
		      </div>
		    		     	  
		    </div>
		    <div class="layui-inline">
		      <button class="layui-btn layui-btn-normal"  onclick="doQuery()">查询/计算</button>
		      <button id="saveQuadrants" class="layui-btn" title="边界值修改后，确定有用，可以保存，以便后续使用" onclick="saveQuadrants()">保存边界值</button>
		      <span class='alert_input'></span>
		 	</div>			   			    
		  </div>		   	  	 				
	</div> 
	 
	<div id="modal" class="modal-industry modal fade" style="display:none">
		<div class="modal-dialog">
			<div class="modal-content">
			   <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title"></h4>
                    <span class='alert_input_modal'></span>
               </div>
  			   <div class="modal-body-industry modal-body">
                    <div class="form-group">
                        <label>
                        	所属行业：<input id="industryName" type="text" class="form-control" name="industryName" placeholder="所属行业" readonly="readonly" style="width:150px;">
                        	&nbsp;&nbsp;方案标题：<input id="title" type="text" class="form-control" name="title" placeholder="标题可填写2级行业">
							&nbsp;&nbsp;备注： <input id="remark" type="text" class="form-control" name="remark" placeholder="备注">                      
                        </label>                                              
                    </div>                		             		
<!--                <div class="form-group">
                        <label>推广日期：</label>
                        <input id="promotionDate" type="text" class="form-control" name="promotionDate" placeholder="推广日期">
                    </div>   -->              		
                    <div class="form-group">
                        <label title="可以复制">推广关键词：</label>
                        <textarea id="promotionKeyword" placeholder="请输入内容" class="layui-textarea" name="promotionKeyword" readonly="readonly"></textarea>
                    </div>                		
                    <div class="form-group">
                        <label title="可以复制">搜索关键词：</label>
                        <textarea id="keywordSearch" placeholder="请输入内容" class="layui-textarea" name="keywordSearch" readonly="readonly"></textarea>
                    </div>             		                  
                </div>    		
                <div class="modal-footer">
                    <button id="closeBut" type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <!-- <button type="button" class="btn btn-primary submit" onclick="subKeyword()">保存</button> -->
                </div>		
			</div>
		</div>
	</div>	 
	
	  <p class="toolbar">      	
	  		<!-- <button id="saveKeyword" class="layui-btn" style="height:30px;line-height:3px;" title="勾选后，确定有用，可以保存" onclick="saveKeyword()">保存最优关键词</button> -->
	        <button type="button" class="export-excel btn btn-primary btn-xs" data-table="#table">导出Excel</button>
	        <span class="alert"></span>
	   </p>
	     
       <table id="table" 
	          data-show-refresh="true"
              data-search="true"
              data-click-to-select="true"
              data-show-export="true"
              data-query-params="queryParams"
		   	  data-pagination="true"		   
              data-toolbar=".toolbar"					 
              >
              <!-- data-show-columns="true" -->
           <thead>
           <tr>
           	   <th data-field="state" data-checkbox="true"></th>
           	   <th data-field="id" data-visible="false">id</th>
               <th data-field="industryId" data-visible="false">行业id</th>
               <th data-field="industryName">所属行业</th>
               <th data-field="companyName">公司名称</th>
               <th data-field="accountId" data-visible="false">账号id</th>
               <th data-field="loginName" data-visible="false">推广账号</th>
               <th data-field="promotionDate" data-sortable="true">推广时间</th>
               <th data-field="promotionPlan">推广计划</th>
               <th data-field="promotionUnit">推广单元</th>
               <th data-field="promotionKeyword">推广关键词</th>
               <th data-field="keywordSearch">搜索关键词</th>
               <th data-field="numberExhibit" data-sortable="true">展现量</th>
               <th data-field="numberClick" data-sortable="true">点击量</th>
               <th data-field="consume" data-sortable="true">消费</th>
               <th data-field="clickRate" data-sortable="true">点击率</th>
               <th data-field="totalnumberConsult" data-sortable="true">总转化量</th>
               <th data-field="consumeConsultRate" data-sortable="true">消费转化比</th>
               <th data-field="quadrantTag" data-sortable="true">象限</th>
           </tr>
          </thead>
       </table>
       
</div>
<script type="text/javascript">	
	//搜索推广计划
	$("#promotionPlan").click(
		function(){			
			//设置页面搜索内容
			$('#table').bootstrapTable('resetSearch', $('#promotionPlan').val());
		}
	);
	
	
</script>

<script>	
  //日期选择代码 
  layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  var start = {
     min: '1970-01-01 23:59:59'
    ,max: laydate.now()
    ,istoday: false
    ,choose: function(datas){
      end.min = datas; //开始日选好后，重置结束日的最小日期
      end.start = datas //将结束日的初始值设定为开始日
    }
  };
  
  var end = {
     min: '1970-01-01 23:59:59'
    ,max:  laydate.now()
    ,istoday: false
    ,choose: function(datas){
      start.max = datas; //结束日选好后，重置开始日的最大日期
    }
  };
  
  document.getElementById('LAY_demorange_s').onclick = function(){
    start.elem = this;
    laydate(start);
  }
  document.getElementById('LAY_demorange_e').onclick = function(){
    end.elem = this
    laydate(end);   
  }
  
 });   
</script>

<script>
	var companyId = ${requestScope.companyId}; //公司id
	var $alert_input = $('.alert_input').hide(); //校验提示
    var $table;
    //加载四象限数据,并初始化table
	loadQuadrant();
   	
    //查询参数 
    function queryQuadrantParams(begintime,endtime) {  //配置参数             	
    	var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的   
    		companyId: companyId,
    		begintime: arguments[0] ? arguments[0] : '',
    		endtime: arguments[1] ? arguments[1] : '',
    		//四象限边界值
    		consumeRateMin_1: $('#consumeRateMin_1').val(),
    		consumeRateMax_1: $('#consumeRateMax_1').val(),
    		consumeRateMin_2: $('#consumeRateMin_2').val(),
	    	consumeRateMax_2: $('#consumeRateMax_2').val(),
	    	consumeRateMin_3: $('#consumeRateMin_3').val(),
	    	consumeRateMax_3: $('#consumeRateMax_3').val(),
	    	consumeRateMin_4: $('#consumeRateMin_4').val(),
	    	consumeRateMax_4: $('#consumeRateMax_4').val()                    
        };  
        return temp;  
    } 
    
    //加载四象限数据,初始化table 
	function loadQuadrant(){		
		var Quadrant_URL = '${pageContext.request.contextPath}/quadrantController.do?getQuadrantsByCompanyId';		  
	       $.ajax({
	           url: Quadrant_URL,
	           type:'GET',
	           contentType: 'application/json',
	           dataType: 'json',
	           data: {companyId: companyId},
	           success: function (data) {         	
	           	var jsonObject = eval(data);//eval()将字符串转成对象数组
	           	$('#quadrant_1').val(jsonObject[0].quadrantId);
	           	$('#quadrant_2').val(jsonObject[1].quadrantId);
	           	$('#quadrant_3').val(jsonObject[2].quadrantId);
	           	$('#quadrant_4').val(jsonObject[3].quadrantId);           	
	           	$('#industry_1').val(jsonObject[0].industryId);
	           	$('#industry_2').val(jsonObject[1].industryId);
	           	$('#industry_3').val(jsonObject[2].industryId);
	           	$('#industry_4').val(jsonObject[3].industryId);           	
	           	$('#consumeRateMin_1').val(jsonObject[0].consumeRateMin);
	           	$('#consumeRateMax_1').val(jsonObject[0].consumeRateMax);
	           	$('#consumeRateMin_2').val(jsonObject[1].consumeRateMin);
	           	$('#consumeRateMax_2').val(jsonObject[1].consumeRateMax);
	           	$('#consumeRateMin_3').val(jsonObject[2].consumeRateMin);
	           	$('#consumeRateMax_3').val(jsonObject[2].consumeRateMax);
	           	$('#consumeRateMin_4').val(jsonObject[3].consumeRateMin);
	           	$('#consumeRateMax_4').val(jsonObject[3].consumeRateMax);
	           	
	           	
	            //初始化table
	           	initTable();
	           
	           },
	           error: function () {
				console.log('加载四象限数据失败');
	           }
	       });
	}
 
	 //初始化table 
    function initTable() {
        var API_URL = '${pageContext.request.contextPath}/promoteDataController.do?getBaiduPromoteData';     	
      	 $table = $('#table').bootstrapTable({
       			url: API_URL,
       			pageSize:500,
       			pageList : [500],
       			//exportDataType: "all",//导出类型  
       			queryParams:queryQuadrantParams(),
       			height: 550, //固定高度，列向可滚动
       			onCheck: function (row) {				
		       				var selectArr = $('#table').bootstrapTable('getSelections'); //勾选的信息	
	       					var keywordOjb= {}; //封装的最优关键词信息(用于显示)		
	       				    var industryName = '',
	       						promotionKeywordArr = '',
	       						keywordSearchArr = '';
	       				    for (var o in selectArr) {	
	       					    industryName = selectArr[o].industryName;
	       					    promotionKeywordArr = promotionKeywordArr + selectArr[o].promotionKeyword + "\n";
	       					    keywordSearchArr = keywordSearchArr + selectArr[o].keywordSearch + "\n";
	       					}		
	       				    keywordOjb['industryName'] = industryName;
	       				    keywordOjb['promotionKeyword'] = promotionKeywordArr;
	       				    keywordOjb['keywordSearch'] = keywordSearchArr;
	       				    		    
	       					//弹出保存信息窗口
	       				    showModal("选择的最优关键词，可以批量复制", keywordOjb);						
		       		     },
      			onUncheck: function (row) {  				
			   				var selectArr = $('#table').bootstrapTable('getSelections'); //勾选的信息	
			   				if(selectArr.length > 0) {
			   					var keywordOjb= {}; //封装的最优关键词信息(用于显示)		
			   				    var industryName = '',
			   						promotionKeywordArr = '',
			   						keywordSearchArr = '';
			   				    for (var o in selectArr) {	
			   					    industryName = selectArr[o].industryName;
			   					    promotionKeywordArr = promotionKeywordArr + selectArr[o].promotionKeyword + "\n";
			   					    keywordSearchArr = keywordSearchArr + selectArr[o].keywordSearch + "\n";
			   					}		
			   				    keywordOjb['industryName'] = industryName;
			   				    keywordOjb['promotionKeyword'] = promotionKeywordArr;
			   				    keywordOjb['keywordSearch'] = keywordSearchArr;
			   				    		    
			   					//弹出保存信息窗口
			   				    showModal("选择的最优关键词，可以批量复制", keywordOjb);						
			   				}
			   				else {
			   					//隐藏窗口
			   					$modal.modal('hide');
			   				}
			   		    }      		
       		
       		});    	             
  	   $modal = $('#modal').modal({show: false}),
	   $alert = $('.alert').hide(),
	   $alert_input = $('.alert_input').hide(),
	   $alert_input_modal = $('.alert_input_modal').hide();
    }
	 
	  //查询代运营公司、推广时段、计算所属四象限
	  function doQuery() {	
		var prevent = false;
    	//检验
    	$('#topContent').find('input[type="text"]').each(function () {       		
    		if($(this).val()=='') {
    			showAlertModal('象限边界值不能为空','danger');
   				prevent = true;
    		}
    		
    		if($(this).attr('id')!='LAY_demorange_s' || $(this).attr('id')!='LAY_demorange_e') {
        		var re = /^[+-]?\d{0,5}\.?\d{0,3}$/;	
        		if(re.exec($(this).val())==null) {
        			showAlertModal('只能输入整数（最大9位）或者保留3位小数的数字','danger');        			
       				prevent = true;
        		}      			
    		}
    		
    	});
        if(prevent==true){
       		//阻止后续提交
        	return false;
        }	  
		  
		var begintime = $("#LAY_demorange_s").val();
		var endtime = $("#LAY_demorange_e").val();
		var query = queryQuadrantParams(begintime,endtime);
		//刷新服务器数据
		$('#table').bootstrapTable('refresh', {query:query});
	  }   
	  
	  //加载推广计划
	  function loadPromotionPlan() {
		$.get("${pageContext.request.contextPath}/promoteDataController.do?baiduPromotePlanSelect",
				{companyId:companyId},
				function(result){
			      var data = $.parseJSON(result);			     
			       for(i=0;i<data.length;i++){				    	  
			    	  $("#promotionPlan").append("<option value='"+data[i]["promotePlan"]+"'>"+data[i]["promotePlan"]+"</option>");
			       }				    	
				}					
		);								
	  }
	
	//保存修改的四象限边界值
	function saveQuadrants() {
		var prevent = false;
    	//检验
    	$('#topContent').find('input[type="text"]').each(function () {       		
    		if($(this).val()=='') {
    			showAlertModal('象限边界值不能为空','danger');
   				prevent = true;
    		}
    		
      		if($(this).attr('id')!='LAY_demorange_s' || $(this).attr('id')!='LAY_demorange_e') {
        		var re = /^[+-]?\d{0,5}\.?\d{0,3}$/;	
        		if(re.exec($(this).val())==null) {
        			showAlertModal('只能输入整数（最大9位）或者保留3位小数的数字','danger');        			
       				prevent = true;
        		}      			
    		}
    		
    	});
        if(prevent==true){
       		//阻止后续提交
        	return false;
        }
        
    	//封装 
		var postArray= new Array();
		var quadrant_1 = new Object();
		quadrant_1.quadrantId=$('#quadrant_1').val();
		quadrant_1.industryId=$('#industry_1').val();
		quadrant_1.consumeRateMin=$('#consumeRateMin_1').val();
		quadrant_1.consumeRateMax=$('#consumeRateMax_1').val();	
		var quadrant_2 = new Object();
		quadrant_2.quadrantId=$('#quadrant_2').val();
		quadrant_2.industryId=$('#industry_2').val();
		quadrant_2.consumeRateMin=$('#consumeRateMin_2').val();
		quadrant_2.consumeRateMax=$('#consumeRateMax_2').val();	
		var quadrant_3 = new Object();
		quadrant_3.quadrantId=$('#quadrant_3').val();
		quadrant_3.industryId=$('#industry_3').val();
		quadrant_3.consumeRateMin=$('#consumeRateMin_3').val();
		quadrant_3.consumeRateMax=$('#consumeRateMax_3').val();	
		var quadrant_4 = new Object();
		quadrant_4.quadrantId=$('#quadrant_4').val();
		quadrant_4.industryId=$('#industry_4').val();
		quadrant_4.consumeRateMin=$('#consumeRateMin_4').val();
		quadrant_4.consumeRateMax=$('#consumeRateMax_4').val();	
		
		postArray.push(quadrant_1);
		postArray.push(quadrant_2);
		postArray.push(quadrant_3);
		postArray.push(quadrant_4);
		
		$.ajax({     
		   url:"${pageContext.request.contextPath}/quadrantController.do?batchUpdateQuadrant",     
		   type:'post',
		   contentType: "application/json; charset=utf-8", //发送数据到服务器时所使用的内容类型。
		   dataType: 'json', //预期的服务器响应的数据类型。
		   data:JSON.stringify(postArray), 
		   success:function(data){
		      if(data.success==true) {
		    	  showAlertModal(data.msg,'success'); 		    	  
		      }
		      else {
		    	  showAlertModal(data.msg,'danger'); 		    	  		    	  
		      }
		   },
           error: function () {
        	   showAlertModal('保存失败，异常', 'danger');
           }
		});		
	}
	
	//弹出窗口
    function showModal(title, keywordOjb) {
    	keywordOjb = keywordOjb || {
        	id: '',
            industryName: '',
            title:'',
            promotionDate:'',
            promotionKeyword:'',
            keywordSearch:'',
            saveDate:'',
            remark:''
        }; 

        $modal.data('id', keywordOjb.id);
        $modal.find('.modal-title').text(title);
        
        for (var name in keywordOjb) {
            $modal.find('input[name="' + name + '"]').val(keywordOjb[name]);
            $modal.find('textarea[name="' + name + '"]').val(keywordOjb[name]);
        } 
        $modal.find('input[name="title"]').val('');//置空标题内容
        
        $modal.find('.modal-title').text(title);
    	$modal.modal('show');
    }

	//提交最优关键词方案
    function subKeyword() {
    	var prevent = false;     	       
	    var postArray= new Array();
        
        //检验
        if($("#title").val() != '') {      	
        	var selectArr = $table.bootstrapTable('getSelections'); //勾选的信息
        	for(var o in selectArr) {
        		var row = {};
        		row['title'] = $("#title").val();
	        	row['industryId'] = selectArr[o].industryId;
	        	row['promotionDate'] = selectArr[o].promotionDate;
	        	row['promotionKeyword'] = selectArr[o].promotionKeyword;
	        	row['keywordSearch'] = selectArr[o].keywordSearch;
	        	row['remark'] = $("#remark").val();
	        	postArray.push(row);
        	}        	
        }
        else {
        	showAlertModal2('方案标题不能为空', 'danger');
        	prevent = true;
        }
        
        if(prevent==true){          		
        	return false;//阻止后续提交
        } 
        
		$.ajax({     
			   url:"${pageContext.request.contextPath}/bestKeywordController.do?batchAdd",     
			   type:'post',
			   contentType: "application/json; charset=utf-8", //发送数据到服务器时所使用的内容类型。
			   dataType: 'json', //预期的服务器响应的数据类型。
			   data:JSON.stringify(postArray), 
			   success:function(data){
			      if(data.success==true) {
					  $modal.modal('hide');
			    	  showAlert(data.msg,'success'); 
			    	  $('#table').bootstrapTable('uncheckAll');//保存成功，清空所选择的关键词信息
			      }
			      else {
			    	  showAlertModal2(data.msg,'danger'); 		    	  		    	  
			      }
			   },
	           error: function () {
	        	   $modal.modal('hide');
	        	   showAlert('保存失败，异常', 'danger');
	           }
		});  	
    }
	
	
	//延迟加载
    $(function () {	   	
	   	//加载推广计划
	   	loadPromotionPlan();	   	
	   	
	   	TableExport.init();
	   	//导出按钮
	   	$('#export').click(function () {	   			   		
	   	  	$table.tableExport({
		   	      type: 'excel',
		   	      escape: false
		   	    });	   	  	
	   	  }); 
	   	
	   	//点击关闭按钮，清空所选择的关键词
        $('#closeBut').click(function () {
        	$('#table').bootstrapTable('uncheckAll');
        }); 	   	
    });

    function showAlert(title, type) {
        $alert.attr('class', 'alert alert-' + type || 'success')
              .html('<i class="glyphicon glyphicon-check"></i> ' + title).show();
        setTimeout(function () {
            $alert.hide();
        }, 3000);
    }   
    function showAlertModal(title, type) {   	
    	$alert_input.attr('class', 'alert alert-' + type || 'success')
              .html('<i class="glyphicon glyphicon-check"></i> ' + title).show();
    	 setTimeout(function () {
    		 	$alert_input.hide();
         }, 3000);      
    } 
    function showAlertModal2(title, type) {   	
    	$alert_input_modal.attr('class', 'alert alert-' + type || 'success')
              .html('<i class="glyphicon glyphicon-check"></i> ' + title).show();
    	 setTimeout(function () {
    		 	$alert_input_modal.hide();
         }, 3000);      
    }   
</script>
   


<%@include file="/webpage/frame/bottom.jsp" %>
</body>

</html>